package com.dn.config;

import com.aliyun.alidns20150109.Client;
import com.aliyun.teaopenapi.models.Config;
import com.dn.MyStart;

import java.time.LocalDateTime;


/**
 * @program: ddns
 * @description: 请求角色创建
 * @author: DN
 * @create: 2021-04-04 12:14
 **/
public class ClientBuilder {


    /**
     * 使用AK&SK初始化账号Client
     * @return Client
     * @throws Exception
     */
    public static Client createClient(String accessKeyId,
                                      String secret,
                                      String endPoint){
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(secret);
        // 访问的域名
        config.endpoint = endPoint;
        try {
            return new Client(config);
        } catch (Exception e) {
            System.out.println(LocalDateTime.now().format(MyStart.formatter)+" -> 创建请求角色失败!");
            e.printStackTrace();
        }
        return null;
    }



}
